package 定时任务;

import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;

/**
 * 作者：idea
 * 日期：2018/8/1
 * 描述：延时队列处理
 */
public class Consumer implements Runnable{

    private DelayQueue<Message> queue;

    public Consumer(DelayQueue<Message> queue){
        this.queue=queue;
    }

    @Override
    public void run() {
        while(true){
            try {
                Message take=queue.take();
                System.out.println("消费信息"+take.getId()+":"+take.getBody());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
